package cn.doitedu.producer.low.datasources;

import java.util.Iterator;
import java.util.Scanner;

public class ConsoleDataSourceIter implements Iterator<String> {

    Scanner scanner = new Scanner(System.in);
    String line;
    boolean flag = false;


    public ConsoleDataSourceIter(String param){

    }


    @Override
    public boolean hasNext() {

        line = scanner.nextLine();

        flag = !line.equals("bye!");

        return flag;
    }


    @Override
    public String next() {

        if(!flag){
            throw new RuntimeException("建议去精神科,不合法的操作");
        }

        return line;
    }
}
